/*
* coder: Dzlua
* email: 505544956@qq.com
* time : 2018-04-17 15:33
*/

#include "ui/ui.hpp"

#include <iostream>
using std::cout;
using std::wcout;
using std::endl;

void show(const ui::string& d) {
    cout << "str:" << d << endl;
}
void wshow(const ui::wstring& d) {
    wcout << L"wstr:" << d << endl;
}
void ushow(const ui::string& d) {
    cout << "ustr:" << ui::u2s(d) << endl;
}
#if defined(_UNICODE) || defined(UNICODE)
    #define tshow wshow
#else
    #define tshow show
#endif

ui::string getstr() {
    char d[5] = { -60, -29, -70, -61, 0 };
    return d;
}
ui::wstring getwstr() {
    wchar_t d[3] = { 0x4f60, 0x597d, 0 };
    return d;
}
ui::string getustr() {
    char d[7] = { -28, -67, -96, -27, -91, -67, 0 };
    return d;
}

void test() {
    ui::string str = getstr();
    auto w = ui::s2w(str);
    auto u = ui::s2u(str);
    auto t = ui::s2t(str);
    show(str);
    wshow(w);
    ushow(u);
    tshow(t);
}

void test_w() {
    ui::wstring str = getwstr();
    auto s = ui::w2s(str);
    auto u = ui::w2u(str);
    auto t = ui::w2t(str);
    wshow(str);
    show(s);
    ushow(u);
    tshow(t);
}

void test_u() {
    ui::string str = getustr();
    auto s = ui::u2s(str);
    auto w = ui::u2w(str);
    auto t = ui::u2t(str);
    ushow(str);
    show(s);
    wshow(w);
    tshow(t);
}


int main(int argc, char** argv)
{
    wcout.imbue(std::locale("", LC_CTYPE));
    
    cout << "-----test-----" << endl;
    test();
    cout << "-----test_w-----" << endl;
    test_w();
    cout << "-----test_u-----" << endl;
    test_u();
    return 0;
}